/*******************************************************************************
* CSCI321 Major Project 2010 - University of Wollongong                        *
********************************************************************************
* Program:		WeaveEdit                                              *
* Authors:		Simon Allen (Student#: 3457527, Unix: sa655)           *
*			Scott Bellis (Student#: 3479110, Unix: sjb900)         *
*			Jason Benger (Student#: 3454137, Unix: jb960)          *
*			Timothy Newmarch (Student#: 3459263 Unix: tgn336)      *
*			Benjamin Richardson (Student# 3467752, Unix: bjr401)   *
* Supervisor:		Daniel F. Saffioti                                     *
* Modified:		28/10/2010                                             *
* Description:		WeaveEdit is a highly portable collaborative text      *
*			editor and word processor, allowing several users to   *
*			read and edit multiple documents at the same time.     *
*			It is available for Mac OS X, Windows and Linux,       *
*			utilising Nokia's Qt development framework.            *
*******************************************************************************/


#include "manual.h"
#include "ui_manual.h"
#include <QUrl>


const char *Manual::DOC_INDEX = "http://www.weaveedit.com/index.html";


Manual::Manual(QWidget *parent) : QDialog(parent), ui(new Ui::Manual)
{
	ui->setupUi(this);

	zoomIn = new QShortcut(QKeySequence(QKeySequence::ZoomIn), this);
	zoomOut = new QShortcut(QKeySequence(QKeySequence::ZoomOut), this);
	zoomFactor = ui->webView->textSizeMultiplier();

	home();

	connect(ui->pushButton_userManual, SIGNAL(clicked()), this, SLOT(userManual()));
	connect(ui->pushButton_techManual, SIGNAL(clicked()), this, SLOT(techManual()));
	connect(ui->pushButton_back, SIGNAL(clicked()), ui->webView, SLOT(back()));
	connect(ui->pushButton_forward, SIGNAL(clicked()), ui->webView, SLOT(forward()));
	connect(ui->pushButton_home, SIGNAL(clicked()), this, SLOT(home()));
	connect(zoomIn, SIGNAL(activated()), this, SLOT(textBigger()));
	connect(zoomOut, SIGNAL(activated()), this, SLOT(textSmaller()));

	ui->webView->setTextSizeMultiplier(1);
}

Manual::~Manual()
{
	delete ui;
}

/**
  * Take the user to WeaveEdit's homepage.
  */
void Manual::home()
{
	ui->webView->load(QUrl(DOC_INDEX));
	ui->webView->show();
}

/**
  * Take the user to the user manual HTML.
  */
void Manual::userManual()
{

}

/**
  * Take the user to the tech manual HTML.
  */
void Manual::techManual()
{

}

/**
  * Decrease text size.
  */
void Manual::textSmaller()
{
	if (zoomFactor > 0.5)
		zoomFactor -= 0.25;

	ui->webView->setTextSizeMultiplier(zoomFactor);
	ui->webView->show();
}

/**
  * Increase text size.
  */
void Manual::textBigger()
{
	if (zoomFactor < 2.0)
		zoomFactor += 0.25;

	ui->webView->setTextSizeMultiplier(zoomFactor);
	ui->webView->show();
}

void Manual::changeEvent(QEvent *e)
{
	QDialog::changeEvent(e);

	switch (e->type())
	{
		case QEvent::LanguageChange:
			ui->retranslateUi(this);

			break;

		default:
			break;
	}
}
